!function(){"use strict";function asyncGeneratorStep(e,t,n,r,o,a,i){try{var c=e[a](i),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(r,o)}function _asyncToGenerator(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var a=e.apply(t,n);function _next(e){asyncGeneratorStep(a,r,o,_next,_throw,"next",e)}function _throw(e){asyncGeneratorStep(a,r,o,_next,_throw,"throw",e)}_next(void 0)}))}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return handle("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),s=r.call(a,"finallyLoc");if(c&&s){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),resetTryEntry(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;resetTryEntry(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:values(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),f}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}(e);var t=e.exports;function _readOnlyError(e){throw new TypeError('"'+e+'" is read-only')}function smForEach(e,t){return 1===arguments.length?function(t){return smForEach(e,t)}:(t.forEach((function(t,n,r){e(t,n,r)})),!0)}function smMap(e,t){if(1===arguments.length)return function(t){return smMap(e,t)};var n=new t.constructor,r=Object.keys(t),o=Array.isArray(t);return r.forEach((function(r){o?n.push(e(t[r])):n[r]=e(t[r])})),n}function smFilter(e,t){if(1===arguments.length)return function(t){return smFilter(e,t)};var n=new t.constructor,r=Object.keys(t),o=Array.isArray(t);return r.forEach((function(r){e(t[r])&&(o?n.push(t[r]):n[r]=t[r])})),n}function smReduce(e,t,n){if(2===arguments.length)return function(n){return smReduce(e,t,n)};if(1===arguments.length)return function(t){return smReduce(e,0,t)};var r=t;return n.forEach((function(t){r=e(r,t)})),r}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function _typeof(e){return typeof e}:function _typeof(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _slicedToArray(e,t){return function _arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function _iterableToArrayLimit(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a=[],i=!0,c=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){c=!0,o=e}finally{try{i||null==n.return||n.return()}finally{if(c)throw o}}return a}}(e,t)||_unsupportedIterableToArray(e,t)||function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var n=function stringify(e){var t=[],n=function push(n,r){e instanceof Array?t.push(r):t.push('"'.concat(n,'":').concat(r))};return Object.keys(e).forEach((function(t){switch(_typeof(e[t])){case"string":n(t,'"'.concat(encodeURI(e[t].replace(/"/g,'\\"')),'"'));break;case"object":e[t]&&n(t,stringify(e[t]));break;case"undefined":case"function":break;default:n(t,e[t])}})),e instanceof Array?"[".concat(t.join(","),"]"):"{".concat(t.join(","),"}")};function ownKeys$9(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function _objectSpread$9(e){for(var t=1;t2?o-2:0),i=2;i>e/4).toString(16)}))},v=function removeDashesFromUUID(e){if(e)return e.slice(0).replace(/-/g,"")},g=function getRandomInt(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e},w=function extractUrlParams(){return window.location.search.substr(1).split("&").reduce((function(e,t){var n=t.split("="),r=n[0],o=decodeURIComponent(n[1]||"");return"true"===o.trim().toLowerCase()||"false"===o?o=Boolean(o):isNaN(Number(o))||(o=Number(o)),e[r]=o,e}),{})},b=function getNow(){var e=new Date,t=e.getDate(),n=e.getMonth()+1;return t<10&&(t="0"+t),n<10&&(n="0"+n),{date:e.getFullYear()+"-"+n+"-"+t+" "+e.getUTCHours()+":"+e.getMinutes()+":"+e.getSeconds(),timestamp:e.valueOf()}},_=function pastDaysFromNowUTCSince(e){return Math.floor((Date.now()-e)/864e5)};function ownKeys$7(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function _objectSpread$7(e){for(var t=1;t1&&void 0!==arguments[1]&&arguments[1],n=this.localStorage.getItem(t?e:R(e));return!n||"["!==n[0]&&"{"!==n[0]?n:JSON.parse(n)},this.set=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.localStorage.setItem(n?e:R(e),"object"===_typeof(t)?JSON.stringify(t):t),t},this.remove=function(e){this.localStorage.removeItem(R(e))},this.clear=function(){this.localStorage.clear()}},G=o.storageKeyPrefix,M=new function CookieStorageRepository(){var e=!1;this.document={},this.init=function(t){e||(this.document=window.document,e=!0)},this.get=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=[],r=this.document.cookie.split(";"),o=new RegExp("".concat(t?e:G+e,"=\\s*(.*)?"),"iu"),a=0;a=1?c[0]:void 0},this.set=function(e,t,n){return n=n||new Date("18 Dec 2100 12:00:00 UTC"),this.document.cookie="".concat(G+e,"=").concat(t,"; expires=").concat(n.toGMTString(),"; path=/"),t},this.remove=function(e){this.document.cookie="".concat(G+e,"=;expires=Thu, 01 Jan 1970 00:00:00 GMT")},this.clearAll=function(){for(var e=this.document.cookie.split(";"),t=0;t-1?n.substr(0,r):n;this.document.cookie="".concat(G+o,"=;expires=Thu, 01 Jan 1970 00:00:00 GMT")}}};function ownKeys$6(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function _objectSpread$6(e){for(var t=1;t>>32-t}var n,r,o,a,i,c,s,u,l,p=function cvtHex(e){var t,n="";for(t=7;t>=0;t--)n+=(e>>>4*t&15).toString(16);return n},f=new Array(80),h=1732584193,d=4023233417,y=2562383102,m=271733878,v=3285377520,g=(e=function utf8Encode(e){e=e.replace(/\r\n/g,"\n");for(var t="",n=0;n127&&r<2048?(t+=String.fromCharCode(r>>6|192),t+=String.fromCharCode(63&r|128)):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128),t+=String.fromCharCode(63&r|128))}return t}(e)).length,w=[];for(r=0;r>>29),w.push(g<<3&4294967295),n=0;n0&&void 0!==arguments[0]?arguments[0]:{};this.personId=e.personId||"anonymous",this.clientId=e.clientId||m(),this.randomNumber=e.randomNumber||g(0,100),this.optIns=e.optIns||[],this.personData=e.personData||{}};function ownKeys$4(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function _objectSpread$4(e){for(var t=1;t3&&void 0!==arguments[3]&&arguments[3],a=Q.getSmObj(),i=q.shouldInjectCrawler?window.sm__dataLayer:void 0,c=void 0;i&&o&&"cart"===window.sm__preDataLayer.type&&window.sm__preDataLayer.externalUrl&&(c=window.sm__preDataLayer.externalUrl,null===(r=window.sm__preDataLayer)||void 0===r||delete r.externalUrl);if(Object.keys(i).length>1&&o)for(var s in i){var u;s!==(null===(u=window.sm__preDataLayer)||void 0===u?void 0:u.type)&&delete i[s]}return{customerId:q.getCustomerId(),createDate:b().date,personId:a&&"anonymous"!==a.personId?a.personId:void 0,clientId:a.clientId,url:window.encodeURIComponent(c||e),referer:window.encodeURIComponent(t),metadata:i}},ne=new function BehaviorService(){this.init=function(){var n=this;this.timeout=setTimeout(_asyncToGenerator(t.mark((function _callee(){var r;return t.wrap((function _callee$(t){for(;;)switch(t.prev=t.next){case 0:if(d.log("behavior","Aggregate timeout. Sending behaviors.."),!(r=e()).length){t.next=5;break}return t.next=5,n.dispatchBehaviors(r);case 5:case"end":return t.stop()}}),_callee)}))),o.behaviorTimeOut)},this.sendBehavior=function(){var n=_asyncToGenerator(t.mark((function _callee3(n,r,o){var a,i=this,c=arguments;return t.wrap((function _callee3$(s){for(;;)switch(s.prev=s.next){case 0:return a=c.length>3&&void 0!==c[3]&&c[3],s.abrupt("return",new Promise(function(){var c=_asyncToGenerator(t.mark((function _callee2(c,s){var u,l;return t.wrap((function _callee2$(t){for(;;)switch(t.prev=t.next){case 0:if(ee()){t.next=3;break}return c(),t.abrupt("return");case 3:if(u=te(n,r,o,a),(l=e()).push(u),N.set("behaviors",l),!(l.length>=5)){t.next=11;break}return t.next=10,i.dispatchBehaviors(l);case 10:i.timeout&&clearTimeout(i.timeout);case 11:c();case 12:case"end":return t.stop()}}),_callee2)})));return function(e,t){return c.apply(this,arguments)}}()));case 2:case"end":return s.stop()}}),_callee3)})));return function(e,t,r){return n.apply(this,arguments)}}(),this.dispatchBehaviors=function(){var e=_asyncToGenerator(t.mark((function _callee5(e){return t.wrap((function _callee5$(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise(function(){var n=_asyncToGenerator(t.mark((function _callee4(n,r){return t.wrap((function _callee4$(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,B.post("enterprise/behaviors",null,{Behaviors:e});case 3:e.length=0,N.set("behaviors",e),n(),t.next=12;break;case 8:t.prev=8,t.t0=t.catch(0),d.warn("Behaviors","Error when trying to dispatch behaviors.",t.t0),r();case 12:case"end":return t.stop()}}),_callee4,null,[[0,8]])})));return function(e,t){return n.apply(this,arguments)}}()));case 1:case"end":return n.stop()}}),_callee5)})));return function(t){return e.apply(this,arguments)}}();var e=function getRegistry(){return N.get("behaviors")||[]};this.clearBehaviorTimeout=function(){this.timeout&&clearTimeout(this.timeout)}},re=function _createEvent(e){var t=Q.getSmObj();return{customerId:q.getCustomerId(),personId:t&&"anonymous"!==t.personId?t.personId:void 0,channelId:e.channelId,type:e.type,step:e.step,clientId:t.clientId,sessionHash:V.getSessionGuid(),systemId:l,dateTime:e.createDate||b().date,additionalData:encodeURI(JSON.stringify(e.additionalData||{}))}},oe=new function EventService(){var e=!1;this.init=function(){var e=this;this.interval=setInterval(_asyncToGenerator(t.mark((function _callee(){var r;return t.wrap((function _callee$(t){for(;;)switch(t.prev=t.next){case 0:if(!(r=n()).length){t.next=5;break}return d.log("event","Aggregate interval. Sending events.."),t.next=5,e.dispatchEvents(r);case 5:case"end":return t.stop()}}),_callee)}))),o.eventsTimeOut)},this.sendEvent=function(){var e=_asyncToGenerator(t.mark((function _callee2(e){var r,o,a,i=arguments;return t.wrap((function _callee2$(t){for(;;)switch(t.prev=t.next){case 0:if(r=i.length>1&&void 0!==i[1]&&i[1],o=re(e),(a=n()).push(o),N.set("events",a),!(a.length>=5||r)){t.next=8;break}return t.next=8,this.dispatchEvents(a);case 8:case"end":return t.stop()}}),_callee2,this)})));return function(t){return e.apply(this,arguments)}}(),this.dispatchEvents=function(){var n=_asyncToGenerator(t.mark((function _callee3(n){return t.wrap((function _callee3$(t){for(;;)switch(t.prev=t.next){case 0:if(e){t.next=15;break}return e=!0,t.prev=2,t.next=5,B.post("enterprise/events",null,{Events:n});case 5:n.length=0,N.set("events",n),t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),d.warn("event","Error when trying to dispatch events.",t.t0);case 12:return t.prev=12,e=!1,t.finish(12);case 15:case"end":return t.stop()}}),_callee3,null,[[2,9,12,15]])})));return function(e){return n.apply(this,arguments)}}();var n=function getRegistry(){return N.get("events")||[]};this.feedConveyor=function(e){var t=N.get("events_conveyor")||[];for(t.unshift(e);t.length>10;)t.pop();return N.set("events_conveyor",t),t},this.feedViewsConveyor=function(e){if(!e.step&&function isViewType(e){return e.split(".").includes("View")}(e.type)){var t=N.get("views_coveyor")||[];for(t.unshift(e);t.length>5;)t.pop();N.set("views_coveyor",t)}},this.getViewsConveyor=function(){return N.get("views_coveyor")||[]}},ae={extract:function(){var e=_asyncToGenerator(t.mark((function _callee(){return t.wrap((function _callee$(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,d.log("ACTION",'"Page view" - Behavior'),e.next=4,ne.sendBehavior(window.location.href,window.document.referrer,window[o.smDataLayerKey]);case 4:e.next=9;break;case 6:e.prev=6,e.t0=e.catch(0),d.warn("ACTION",'"send" - error: ',e.t0);case 9:case"end":return e.stop()}}),_callee,null,[[0,6]])})));return function extract(){return e.apply(this,arguments)}}()},ie=function getCrawlerURI(e){return"".concat(o.Endpoints.Static,"/customers/").concat(e._customerId,"/crawler/crawler.js")},ce=function shouldInjectCrawler(e){return e.shouldInjectCrawler},se=function(){var e=_asyncToGenerator(t.mark((function _callee(e){var n,r=arguments;return t.wrap((function _callee$(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.length>1&&void 0!==r[1]?r[1]:20,t.prev=1,0!==e){t.next=4;break}return t.abrupt("return",!1);case 4:if(!window.sm__dataLayer&&!window.sm__preDataLayer){t.next=6;break}return t.abrupt("return",!0);case 6:return d.log("Crawler Injection","Crawling is not finished yet. Checking again in ".concat(n,"ms.")),t.next=9,C(n);case 9:return t.abrupt("return",se(e-1,n+20));case 12:return t.prev=12,t.t0=t.catch(1),d.error("Crawler Injection","Error when checking crawler injection",t.t0),t.abrupt("return",Promise.reject(t.t0));case 16:case"end":return t.stop()}}),_callee,null,[[1,12]])})));return function checkDataLayer(t){return e.apply(this,arguments)}}(),ue=function(){var e=_asyncToGenerator(t.mark((function _callee3(e){return t.wrap((function _callee3$(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise(function(){var n=_asyncToGenerator(t.mark((function _callee2(n,r){return t.wrap((function _callee2$(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,!ce(e)){t.next=6;break}return t.next=4,O({src:ie(e)},window);case 4:d.log("MAIN","Crawler - injected"),se(20).then((function(e){e&&n(),r(new Error("Error when trying to load the crawler."))}));case 6:t.next=12;break;case 8:t.prev=8,t.t0=t.catch(0),d.warn("MAIN","Crawler - failed to inject:",t.t0),r(t.t0);case 12:n();case 13:case"end":return t.stop()}}),_callee2,null,[[0,8]])})));return function(e,t){return n.apply(this,arguments)}}()));case 1:case"end":return n.stop()}}),_callee3)})));return function injectCrawler(t){return e.apply(this,arguments)}}(),le={baseURL:o.Endpoints.WonkaThroughUrsa,expire:o.wonkaTimeout,headers:[{key:"Accept",value:"application/json"}]},pe=function prefetchCustomer(e,t){return new Promise((function(n){d.log("CUSTOMER_R.","[prefetchCustomer] Prefetching Customer: ".concat(e)),new y(le.baseURL,{Headers:le.headers}).get("customers/".concat(e,"?url=").concat(t),null,null).then((function(e){n(W(e.response))}))}))},fe=new function CrawlerService(){this.onDataLayer=function(){var e=_asyncToGenerator(t.mark((function _callee2(e){var n,r=this;return t.wrap((function _callee2$(a){for(;;)switch(a.prev=a.next){case 0:n=window.dataLayer.push,window.dataLayer.push=_asyncToGenerator(t.mark((function _callee(){var a,i,c,s,u,l,p,f=arguments;return t.wrap((function _callee$(t){for(;;)switch(t.prev=t.next){case 0:for(a=f.length,i=new Array(a),c=0;c0)){t.next=15;break}return t.next=12,ne.dispatchBehaviors(a);case 12:ne.clearBehaviorTimeout(),N.set("behaviors",[]),d.log("Action","Behaviors extracted.");case 15:n();case 16:case"end":return t.stop()}}),_callee4)})));return function(e){return n.apply(this,arguments)}}()));case 1:case"end":return n.stop()}}),_callee5)})));return function(t){return e.apply(this,arguments)}}()},he=Object.freeze({__proto__:null,ProfileService:K,CustomerService:q,SessionService:V,BehaviorService:ne,EventService:oe,CrawlerService:fe});function _objectWithoutProperties(e,t){if(null==e)return{};var n,r,o=function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var de=function mapperEvent(e,t,n){try{var r={channelId:e};if(n.additionalData&&(r.additionalData=n.additionalData),!n.type)throw new Error("'type' attribute is missing");var o=we[t].name,a=s[n.type];if(!a)throw new Error("event type not found");if(n.step){var i=u[t][n.step];if(!i)throw new Error("step event type not found");r.type="Channel.".concat(o,".Step.").concat(a),r.step="".concat(o,".").concat(i)}else r.type="Channel.".concat(o,".").concat(a);return r}catch(e){throw new Error("Unable to create event: ".concat(e.message))}};function ownKeys$3(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function _objectSpread$3(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:window,t={alignItems:"center",backgroundColor:"rgba(0, 0, 0, .5)",height:"300px",width:"300px",justifyContent:"center",left:"0",top:"0",position:"fixed",zIndex:"999999999"},n={};this.withStyle=function(e){return t=me[e].container,this},this.withAttribute=function(e,t){return n[e]=t,this},this.build=function(){var r=e.document.createElement("div");return j(r,t),x(r,n),r}},ge=function FrameBuilder(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window,t={height:"100%",width:"100%",border:"0"},n={},r=[],o="";this.withSource=function(e){return o=e,this},this.withStyle=function(e){return t=me[e].frame,this},this.withAttribute=function(e,t){return n[e]=t,this},this.withPermissions=function(e){return smForEach((function(e){return r.push(e)}),e),this},this.build=function(){var a=e.document.createElement("iframe");return a.src=o,j(a,t),x(a,n),S(a,r),a}};function ownKeys$2(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function _objectSpread$2(e){for(var t=1;t6&&void 0!==arguments[6]?arguments[6]:{};ye.call(this,e,t,n,o,a),this.subType=r,this.state=u,this.isOldLightBox=!1,this.isOptinCompleted=!1,this.isJourneyCompleted=!1,this.src="https://".concat("","static.socialminer.com/customers/").concat(this.customerId,"/channels/1/").concat(this.channelId,"/indexB.html");var l=this;function postOptInEmail(e){var t={profileType:i.EMAIL,sourceChannelType:c.LIGHTBOX,channelId:l.channelId,formData:{email:e.email}};Q.optIn(t).then((function(e){l.postMessage({event:"optin-email-response",data:"success"}),l.isOptinCompleted=!0,l.state.hasWaba||(l.isJourneyCompleted=!0)})).catch((function(e){return console.log("Error",e)}))}function postOptInPhone(e){var t={profileType:i.PHONE,sourceChannelType:c.LIGHTBOX,channelId:l.channelId,formData:{phone:e.phone}};Q.optIn(t).then((function(e){l.postMessage({event:"optin-phone-response",data:"success"}),l.isOptinCompleted=!0,l.isJourneyCompleted=!0})).catch((function(e){return console.log("Error",e)}))}function checkOldLightBox(e){e.channelId||(l.isOldLightBox=!0)}function sendEventChannel(e){if(l.isOldLightBox){var r=de(t,n,e),o=b(),a=o.date,i=o.timestamp;oe.feedViewsConveyor(_objectSpread$2(_objectSpread$2({},r),{},{create_date:a,timestamp:i})),oe.sendEvent(r)}}function channelCloseEvent(){l.isJourneyCompleted?sendEventChannel({type:"CONCLUSION"}):l.isOptinCompleted?sendEventChannel({type:"CONCLUSION_WITH_REJECTION"}):sendEventChannel({type:"REJECTION"})}this.onRender=function(){return this.state.container=(new ve).withStyle(l.channelType).withAttribute("id","sm-plugin").build(),this.state.iframe=(new ge).withSource(l.src).withPermissions(["clipboard-read","clipboard-write"]).withStyle(l.channelType).build(),this.state.container.appendChild(this.state.iframe),{container:this.state.container,iframe:this.state.iframe}},this.onReady=function(e){var t=Q.exportSmObj(),n=q.export().hasWaba,r=this.state,o=r.haspluginemail,a=r.haspluginwa;this.state=_objectSpread$2(_objectSpread$2({},this.state),{},{hasWaba:n}),checkOldLightBox(e),this.postMessage({event:"init",data:_objectSpread$2(_objectSpread$2({},t),{},{hasWaba:n,haspluginemail:o,haspluginwa:a,customerId:q.getCustomerId()})})},this.onShow=function(){this.state.container.style.display="flex",sendEventChannel({type:"VIEW"}),window.isPluginOpened=!0},this.onClose=function(){this.state.container.style.display="none",channelCloseEvent()},this.onBlockChannel=function(){var e=Q.exportSmObj();this.state.hasWaba&&e.hasPhone||e.hasEmail?this.blockChannel():this.blockChannel(24)},this.onReceiveMessage=(_defineProperty(s={},"optin-email",(function optinEmail(e){postOptInEmail(e.formData)})),_defineProperty(s,"optin-phone",(function optinPhone(e){postOptInPhone(e.formData)})),s),this.canShow=function(){var e=u.haspluginemail,t=u.haspluginwa,n=q.export().hasWaba;return e||t&&n}}},be=Object.freeze({lightbox:{desktop:{type:"exit"},mobile:{type:"timeout",timeoutInSeconds:"10"}}}),_e={timeout:function Timeout(e){var t,n=e.timeoutInSeconds;this.init=function(e){var r=this;t=window.setTimeout(e,1e3*parseInt(n,10)),document.addEventListener("touchstart",(function(){window.isPluginOpened||(r.destroy(),t=window.setTimeout(e,1e3*parseInt(n,10)))}))},this.destroy=function(){window.clearTimeout(t)}},exit:function Exit(){var e,t=document.documentElement;function handleMouseEvent(t){if(t.clientY<0)return e()}this.init=function(n){e=n,t.addEventListener("mouseleave",handleMouseEvent)},this.destroy=function(){t.removeEventListener("mouseleave",handleMouseEvent)}}},Oe=function _resolveTrigger(e){return _e[e]?_e[e]:null},je=function buildTrigger(e){var t=Oe(e.type);return t?new t(e):null},xe=function buildTriggerByChannelType(e){var t=function getDeviceType(){var e={name:"desktop",identifier:1},t={name:"mobile",identifier:2};if(navigator.userAgentData)return navigator.userAgentData.mobile?t:e;var n=window.matchMedia("(pointer:coarse)");if(n&&n.matches)return t;if(!("ontouchstart"in window))return t;var r=navigator.userAgent||navigator.vendor||window.opera;return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(r)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(r.substr(0,4))?t:e}().name,n=be[e][t],r=Oe(n.type);return r?new r(n):null},Se=function warmUpChannelsWithDefaultTrigger(e,t){smForEach((function(t){var n=t.type,r=t.id,o=_objectWithoutProperties(t,["type","id"]);if(!function isChannelBlocked(e){return!!M.get("channel_".concat(v(e)))}(r)){var a=function getConstructor(e){return we[e]||(d.log("Channel Initilizer","Channel not implemented."),null)}(n);if(a){var i=xe(n);new a(e,r,n,"","",[i],o).init()}else d.log("Channel Initilizer","Could not warmup channel with id.",r)}}),t)},Ce=function getCommonScriptURI(e){if(!(e.storeId>0&&e.appAuth))return"".concat(o.Endpoints.Static,"/custom/").concat(e._customerId,"/custom.js");var t=e.providerName[0].toUpperCase()+e.providerName.substring(1).toLowerCase();return t?"".concat(o.Endpoints.Static,"/mastertag/").concat(t,"/common.js"):"".concat(o.Endpoints.Static,"/mastertag/common.js")},Ie=function(){var e=_asyncToGenerator(t.mark((function _callee(e){var n,r=arguments;return t.wrap((function _callee$(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.length>1&&void 0!==r[1]?r[1]:20,t.prev=1,0!==e){t.next=4;break}return t.abrupt("return",!1);case 4:if(!Q.isOrganicOptinFinished()){t.next=6;break}return t.abrupt("return",!0);case 6:return d.log("Organic Optin","Organic opt-in is not finished yet. Checking again in ".concat(n,"ms.")),t.next=9,C(n);case 9:return t.abrupt("return",Ie(e-1,n+20));case 12:return t.prev=12,t.t0=t.catch(1),d.error("Oganic-Optin","Error when checking organic optin",t.t0),t.abrupt("return",Promise.reject(t.t0));case 16:case"end":return t.stop()}}),_callee,null,[[1,12]])})));return function checkOrganicOptin(t){return e.apply(this,arguments)}}(),ke=function(){var e=_asyncToGenerator(t.mark((function _callee2(e){return t.wrap((function _callee2$(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,O({src:Ce(e)},window);case 3:return d.log("MAIN","Common Script - injected"),t.abrupt("return",new Promise((function(e,t){Ie(10).then((function(n){n&&e(),t(new Error("Error when trying to load organic opt-in script."))}))})));case 7:return t.prev=7,t.t0=t.catch(0),d.warn("MAIN","Common Script - failed to inject:",t.t0),t.abrupt("return",Promise.reject(t.t0));case 11:case"end":return t.stop()}}),_callee2,null,[[0,7]])})));return function processOrganicOptin(t){return e.apply(this,arguments)}}();function ownKeys$1(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function _objectSpread$1(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:{};window.sm__preDataLayer=e}function createPreDataLayer(e,t,n){var r={type:e,details:t};return n&&(r.externalUrl=n),r}function bagyLog(e){d.log("BAGY",e)}function executeOptin(e){return _executeOptin.apply(this,arguments)}function _executeOptin(){return(_executeOptin=_asyncToGenerator(t.mark((function _callee5(e){return t.wrap((function _callee5$(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise(function(){var n=_asyncToGenerator(t.mark((function _callee4(n){return t.wrap((function _callee4$(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Q.organicOptin(e);case 2:Q.finishOrganicOptin(),n();case 4:case"end":return t.stop()}}),_callee4)})));return function(e){return n.apply(this,arguments)}}()));case 1:case"end":return n.stop()}}),_callee5)})))).apply(this,arguments)}function injectCrawler(e){return _injectCrawler.apply(this,arguments)}function _injectCrawler(){return(_injectCrawler=_asyncToGenerator(t.mark((function _callee7(e){return t.wrap((function _callee7$(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise(function(){var n=_asyncToGenerator(t.mark((function _callee6(n){return t.wrap((function _callee6$(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fe.injectCrawlerAndCleanBehaviors(e);case 2:n();case 3:case"end":return t.stop()}}),_callee6)})));return function(e){return n.apply(this,arguments)}}()));case 1:case"end":return n.stop()}}),_callee7)})))).apply(this,arguments)}var Pe=[],Te=!1;function listenToEvent(e,n,r){document.addEventListener("tracker.".concat(e),function(){var e=_asyncToGenerator(t.mark((function _callee(e){var o,a;return t.wrap((function _callee$(t){for(;;)switch(t.prev=t.next){case 0:return o=e.detail,t.next=3,n(o);case 3:if(!(a=t.sent)){t.next=9;break}if(Pe.push({obj:a,customerId:r}),Te){t.next=9;break}return t.next=9,executeNextEvent();case 9:case"end":return t.stop()}}),_callee)})));return function(t){return e.apply(this,arguments)}}())}function executeNextEvent(){return _executeNextEvent.apply(this,arguments)}function _executeNextEvent(){return(_executeNextEvent=_asyncToGenerator(t.mark((function _callee8(){var e,n,r;return t.wrap((function _callee8$(t){for(;;)switch(t.prev=t.next){case 0:if(0!==Pe.length){t.next=3;break}return Te=!1,t.abrupt("return");case 3:return Te=!0,e=Pe.shift(),n=e.obj,r=e.customerId,setPreDataLayer(n),t.next=8,injectCrawler(r);case 8:return Te=!1,bagyLog("Event successfully listened"),t.next=12,executeNextEvent();case 12:case"end":return t.stop()}}),_callee8)})))).apply(this,arguments)}var Ae=Object.freeze({viewProduct:"viewProduct",viewCollection:"viewCollection",search:"search",viewCart:"viewCart",purchase:"purchase",signIn:"signIn",signUp:"signUp"}),De=function cartPreDataLayer(){var e=M.get("_dc_cart",!0);if(e)return createPreDataLayer("cart",{},"".concat(window.location.origin,"/carrinho?cart_token=").concat(e))},Le=function(){var e=_asyncToGenerator(t.mark((function _callee3(e){var n,r,o;return t.wrap((function _callee3$(a){for(;;)switch(a.prev=a.next){case 0:if(setPreDataLayer(),window.location.href.includes("cupom")&&(r=new URLSearchParams(window.location.search),o=r.get("cupom"),N.set("_dc_coupon_code",o,!0)),listenToEvent(Ae.viewProduct,(function(e){var t;return createPreDataLayer("product",{name:e.name||void 0,price:e.price||void 0,available:(null===(t=e.variation)||void 0===t?void 0:t.balance)>0?"YES":"NO",category:e.category||void 0})}),e),listenToEvent(Ae.viewCollection,(function(e){if(e.name)return createPreDataLayer("category",{category:e.name})}),e),listenToEvent(Ae.search,(function(e){if(e.q)return createPreDataLayer("search",{query:e.q})}),e),listenToEvent(Ae.signIn,function(){var e=_asyncToGenerator(t.mark((function _callee2(e){var n;return t.wrap((function _callee2$(t){for(;;)switch(t.prev=t.next){case 0:if(!(n={email:e.email,name:"".concat(e.first_name," ").concat(e.last_name)||e.name}).email||!n.name){t.next=8;break}return t.next=4,executeOptin(n);case 4:if(!window.location.href.includes("checkout")){t.next=8;break}return t.next=7,C(2e3);case 7:return t.abrupt("return",De());case 8:case"end":return t.stop()}}),_callee2)})));return function(t){return e.apply(this,arguments)}}(),e),listenToEvent(Ae.signUp,(function(e){var t={email:e.email,name:"".concat(e.first_name," ").concat(e.last_name)||e.name};t.email&&t.name&&executeOptin(t)}),e),listenToEvent(Ae.viewCart,(function(e){return De()}),e),listenToEvent(Ae.purchase,(function(e){return createPreDataLayer("purchase",{})}),e),bagyLog("Events successfully registered"),"index"!==(null===(n=window.dooca)||void 0===n?void 0:n.template)){a.next=13;break}return Pe.push({obj:createPreDataLayer("home",{}),customerId:e}),a.abrupt("return",!0);case 13:return a.abrupt("return",!1);case 14:case"end":return a.stop()}}),_callee3)})));return function initBagyEvents(t){return e.apply(this,arguments)}}(),$e=Object.freeze({bagy:"BAGY"}),Re={create:{action:function action(e,n){return _asyncToGenerator(t.mark((function _callee(){var r,o,a,i;return t.wrap((function _callee$(t){for(;;)switch(t.prev=t.next){case 0:t.prev=0,d.log("Allminer SDK","Initializing all services..."),N.init(),M.init(),r=!1,t.t0=null==n?void 0:n.toUpperCase(),t.next=t.t0===$e.bagy?8:12;break;case 8:return d.log("BAGY","Initializing event listeners..."),t.next=11,Le(e);case 11:r=t.sent;case 12:return t.next=14,pe(e,decodeURIComponent(window.location));case 14:return o=t.sent,a=ue(o),D.init(),V.init(),oe.init(),ne.init(),fe.onDataLayer(e),q.import(o),Q.init(),t.next=25,ke(o);case 25:return i=t.sent,Se(q.getCustomerId(),q.export().channelsData),t.next=29,Promise.all([a,i]);case 29:if(!r||Te){t.next=32;break}return t.next=32,executeNextEvent();case 32:t.next=37;break;case 34:t.prev=34,t.t1=t.catch(0),d.error("SDK initialization","Something wrong happened.",t.t1);case 37:case"end":return t.stop()}}),_callee,null,[[0,34]])})))()},shouldHoldQueue:!0},render:{action:function action(e,t){smFilter((function(n){return n.id===t&&n.type===e}),q.channelsData).length?(d.log("Channel Render","Customer has the specified channel."),function initializeChannel(e,t,n){var r=we[t];r?new r([je({type:"timeout",timeoutInSeconds:"1"})],e,t,n).init():d.log("Channel Initilizer","Channel not implemented.")}(q.getCustomerId(),e,t)):d.log("Channel Render","Customer has not the specified channel.")}},send:{action:function action(e,n){return _asyncToGenerator(t.mark((function _callee2(){return t.wrap((function _callee2$(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e.toLowerCase(),t.next="pageview"===t.t0?3:10;break;case 3:switch(d.log("ACTION",'"send" - Page view'),!0,null==n?void 0:n.toUpperCase()){case $e.bagy:_readOnlyError("initBehaviors")}return ae.extract().then((function(){return d.log("Action","Behaviors extracted.")})),Ee.extract().then((function(){return d.log("Action","Event extracted.")})),d.log("ACTION",'"send" - done'),t.abrupt("break",11);case 10:d.warn("ACTION",'Unknown action of type "'.concat(e,'"'));case 11:case"end":return t.stop()}}),_callee2)})))()}},organicOptin:{action:function action(){return _asyncToGenerator(t.mark((function _callee3(){return t.wrap((function _callee3$(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ke();case 2:case"end":return e.stop()}}),_callee3)})))()}},optIn:{action:function action(e){Q.optIn(e).then((function(e){return console.log("done!",e)})).catch((function(e){return console.log("Erro: ",e)}))}}};function runAction(){return _runAction.apply(this,arguments)}function _runAction(){return(_runAction=_asyncToGenerator(t.mark((function _callee(){var e,n,r=arguments;return t.wrap((function _callee$(t){for(;;)switch(t.prev=t.next){case 0:if(e=[].slice.call(r),!(n=Re[e[0]])){t.next=7;break}return t.next=5,n.action.apply(n,_toConsumableArray(e.slice(1)));case 5:t.next=8;break;case 7:d.log("Not implemented","Method '".concat(e[0].toUpperCase(),"' doesn't exist."));case 8:case"end":return t.stop()}}),_callee)})))).apply(this,arguments)}var Ne=function ServiceRelayType(){Object.assign(this,he,F,Z),this.w=window,this.hostSite=window.hostSite};function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(e,t){return e.__proto__=t,e})(e,t)}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function _construct(e,t,n){return(_construct=_isNativeReflectConstruct()?Reflect.construct:function _construct(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&_setPrototypeOf(o,n.prototype),o}).apply(null,arguments)}function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function _objectSpread(e){for(var t=1;t1&&void 0!==arguments[1]&&arguments[1],n=function actionAsPromise(){return new Promise((function(t,n){try{t(e())}catch(e){n(e)}})).catch((function(e){console.warn(e)})).finally((function(e){return o(actionAsPromise),e}))};r.push({action:n,hold:t}),a()}((i=e[c].action).bind.apply(i,[n].concat(_toConsumableArray(s))),!!e[c].shouldHoldQueue)}))},Me=window,Ue=smMap((function(e){return _toConsumableArray(e)}),(Me[Me.SocialMinerObject]||{}).q);(function(){var e=_asyncToGenerator(t.mark((function _callee(){return t.wrap((function _callee$(e){for(;;)switch(e.prev=e.next){case 0:k();try{runAction.Main=new Ne,runAction.ActionQueue=new Ge(Re,Ue),Me[Me.SocialMinerObject]=runAction}catch(e){d.error("ALLMinerSDK","Error initializing SDK",e)}case 2:case"end":return e.stop()}}),_callee)})));return function init(){return e.apply(this,arguments)}})()()}();